//
//  LXDetailsViewController.m
//  灵秀
//
//  Created by 李田 on 17/3/19.
//  Copyright © 2017年 tianyao. All rights reserved.
//

#import "LXDetailsViewController.h"
#import "LXFoodDetailModel.h"
#import "LXDetailsHeaderView.h"

@interface LXDetailsViewController ()<UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *topImageView;
@property (weak, nonatomic) IBOutlet UITableView *myTable;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topImageHeightContstraint;

@end

@implementation LXDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

#pragma mark - 2.0图片放大缩小
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    // 获取滚动的偏移量
    CGPoint offset =  scrollView.contentOffset;

    CGFloat height = -offset.y;
    
    _topImageHeightContstraint.constant = height;
}


#pragma mark - 1.0 搭建界面
- (void)setupUI {
    
    _myTable.contentInset = UIEdgeInsetsMake(200, 0, 0, 0);
    
    _myTable.backgroundColor = [UIColor clearColor];
    
    //添加 一个空的 footerView
    _myTable.tableFooterView = [[UIView alloc]init];
    
    //隐藏滚动条
    _myTable.showsVerticalScrollIndicator = NO;
    
    // 代理
    _myTable.delegate = self;
    
    // 设置图片
    NSString *str = [_detailsModel.picture stringByDeletingPathExtension];
    
    [_topImageView sd_setImageWithURL:[NSURL URLWithString:str]];
    LXDetailsHeaderView *headView = [LXDetailsHeaderView detailsHeadView];
    
    headView.model = _detailsModel;
    
    _myTable.tableHeaderView = headView;
}

@end
